<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="isemiretut" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{isemiretutHome.managed ? 'Edit' : 'Add'} Isemiretut</f:facet>

			<rich:layout>
              	<rich:layoutPanel position="left">

			        <s:decorate id="turComboField" template="layout/edit.xhtml">
			            <ui:define name="label">Tür</ui:define>
			            <h:selectOneMenu id="turCombo" value="#{isemiretutHome.instance.tur}">
						  <f:selectItems value="#{isemiretutHome.etutTuru}" />
						  <!--			  <s:convertEnum/>-->
						</h:selectOneMenu>
			        </s:decorate>  
		            
		            <s:decorate id="islemnoField" template="layout/edit.xhtml">
		                <ui:define name="label">Islemno</ui:define>
		                <h:inputText id="islemno" required="true" value="#{isemiretutHome.instance.islemno}"/>
		            </s:decorate>

		             <s:decorate id="extendedDataTableField" template="layout/edit.xhtml">
		                <ui:define name="label">Ürün</ui:define>
		                	<h:panelGrid columns="3">
								<h:panelGroup>
									<h:graphicImage id="link" value="/img/selection.png" styleClass="hidelink"/>
                					<rich:componentControl for="popup" attachTo="link" operation="show" event="onclick"/>
							    </h:panelGroup>
					     	
					     		<h:outputLabel value="   " /> 
					     			
			                	<h:outputLabel value="#{isemiretutHome.instance.urun==null ? 'Ürün Seç' : isemiretutHome.instance.urun.adi}   #{isemiretutHome.instance.urun==null ? ' ' : isemiretutHome.instance.urun.ambalaj}" />
			                </h:panelGrid>
		            </s:decorate>

		
					<s:decorate id="kalipekiField" template="layout/edit.xhtml">
		                <ui:define name="label">Kalipeki</ui:define>
		                <h:inputText id="kalipeki" value="#{isemiretutHome.instance.kalipeki}"/>
		            </s:decorate>
		            
				</rich:layoutPanel>
				
				<rich:layoutPanel position="center">
		            
		            <s:decorate id="uruniciadetField" template="layout/edit.xhtml">
		                <ui:define name="label">Uruniciadet</ui:define>
		                <h:inputText id="uruniciadet" value="#{isemiretutHome.instance.uruniciadet}"/>
		            </s:decorate>
		            
		            <s:decorate id="kirikField" template="layout/edit.xhtml">
		                <ui:define name="label">Kirik</ui:define>
		                <h:inputText id="kirik" value="#{isemiretutHome.instance.kirik}">
		                    <a:support event="onblur" reRender="kirikField" bypassUpdates="true" ajaxSingle="true"/>
		                </h:inputText>
		            </s:decorate>
		
		            <s:decorate id="planfiyatField" template="layout/edit.xhtml">
		                <ui:define name="label">Planfiyat</ui:define>
		                <h:inputText id="planfiyat" value="#{isemiretutHome.instance.planfiyat}">
		                    <a:support event="onblur" reRender="planfiyatField" bypassUpdates="true" ajaxSingle="true"/>
		                </h:inputText>
		            </s:decorate>                 

					<s:decorate id="paraBirimiField" template="layout/edit.xhtml">
		                <ui:define name="label">Para Birimi</ui:define>
				      	<h:selectOneMenu  width="250" value="#{isemiretutHome.instance.parabirim}" required="true">
							<s:selectItems value="#{parabirimList.resultList}" var="paraBirimi" label="#{paraBirimi.kisaad} - #{paraBirimi.ad}" noSelectionLabel="Seçim Yapınız!"  />
							<s:convertEntity />
						</h:selectOneMenu>
					</s:decorate>       
		            
					
				</rich:layoutPanel>
			</rich:layout>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{isemiretutHome.persist}"
                       disabled="#{!isemiretutHome.wired}"
                       rendered="#{!isemiretutHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{isemiretutHome.update}"
                       rendered="#{isemiretutHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{isemiretutHome.remove}"
                      immediate="true"
                       rendered="#{isemiretutHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Isemiretut.xhtml"
                rendered="#{isemiretutHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty isemiretutFrom ? 'IsemiretutList' : isemiretutFrom}.xhtml"
                rendered="#{!isemiretutHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Isemir *" labelClass="required">
    <div class="association" id="isemirParent">

        <h:outputText value="There is no isemir associated with this isemiretut."
                   rendered="#{isemiretutHome.instance.isemir == null}"/>

        <rich:dataTable var="_isemir"
                   value="#{isemiretutHome.instance.isemir}"
                rendered="#{isemiretutHome.instance.isemir != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="isemirTable">
        <h:column>
            <f:facet name="header">Id</f:facet>
            <h:outputText value="#{_isemir.id}"/>
        </h:column>
        <h:column>
            <f:facet name="header">Isemirno</f:facet>
            <h:outputText value="#{_isemir.isemirno}"/>
        </h:column>
        <h:column rendered="#{authenticator.isAdmin()}">
            <f:facet name="header">Firma id</f:facet>
            <h:outputText value="#{_isemir.firma.ad}"/>
        </h:column>
        <h:column>
            <f:facet name="header">Isemirtarihi</f:facet>
            <h:outputText value="#{_isemir.isemirtarihi}">
                <s:convertDateTime type="date" dateStyle="short"/>
            </h:outputText>
        </h:column>
        <h:column>
            <f:facet name="header">Isletme id</f:facet>
            <h:outputText value="#{_isemir.isletme.ad}"/>
        </h:column>
        <h:column>
            <f:facet name="header">Siparisno</f:facet>
            <h:outputText value="#{_isemir.siparisno}"/>
        </h:column>        
        <h:column>
            <f:facet name="header">Urun id</f:facet>
            <h:outputText value="#{_isemir.urun.urunno} - #{_isemir.urun.adi} ( #{_isemir.urun.kalip.kod} #{_isemir.urun.ambalaj})"/>
        </h:column>        
        <h:column>
            <f:facet name="header">Musteri id</f:facet>
            <h:outputText value="#{_isemir.musteri.ad}"/>
        </h:column>
        <h:column>
            <f:facet name="header">Planlananadet</f:facet>
            <h:outputText value="#{_isemir.planlananadet}"/>
        </h:column>
        <h:column>
            <f:facet name="header">Termintarihi</f:facet>
            <h:outputText value="#{_isemir.termintarihi}">
                <s:convertDateTime type="date" dateStyle="short"/>
            </h:outputText>
        </h:column>
        <h:column>
            <f:facet name="header">Ulke id</f:facet>
            <h:outputText value="#{_isemir.ulke.ad}"/>
        </h:column>

        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{isemiretutHome.instance.isemir != null ? 'changeParent' : 'selectParent'}" value="#{isemiretutHome.instance.isemir != null ? 'Change' : 'Select'} isemir"
                       view="/IsemirList.xhtml">
                <f:param name="from" value="IsemiretutEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

</rich:tabPanel>

	 <rich:modalPanel id="popup" width="520" height="500" resizeable="false" onmaskclick="#{rich:component('popup')}.hide()">
        <f:facet name="header">
            <h:panelGroup>
                <h:outputText value="Ürün Seçimi"></h:outputText>
            </h:panelGroup>
        </f:facet>
        <f:facet name="controls">
            <h:panelGroup>
                <h:graphicImage value="/img/close.png" styleClass="hidelink" id="hidelink"/>
                <rich:componentControl for="popup" attachTo="hidelink" operation="hide" event="onclick"/>
            </h:panelGroup>
        </f:facet>
		
        <h:panelGrid id="seciliUrunBilgisi">
	        <s:decorate id="kalipekiField" template="layout/edit.xhtml">
	            <ui:define name="label">Seçili Ürün</ui:define>
	            <h:outputLabel value="#{isemiretutHome.instance.urun.adi} - #{isemiretutHome.instance.urun.ambalaj}"/>
	        </s:decorate>
        </h:panelGrid>        
       
        <a:form reRender="seciliUrunBilgisi">
	        <h:panelGrid>
		        	<rich:extendedDataTable rows="10" value="#{isemiretutHome.urunsDataModel}" var="urun" id="table" width="500px" height="350px"
		        		sortMode="#{isemiretutHome.sortMode}" selectionMode="#{isemiretutHome.selectionMode}" 
		        		tableState="#{isemiretutHome.tableState}" selection="#{isemiretutHome.selection}">
		        	   	<a:support event="onselectionchange" reRender="seciliUrunBilgisi,extendedDataTableField" action="#{isemiretutHome.takeSelection()}"/>
		               	<rich:column sortable="true" sortBy="#{urun.urunno}" id="col_2" 
		               		filterBy="#{urun.urunno}" filterEvent="onkeyup" width="170px" label="Ürün No">
		                   	<f:facet name="header">
		                    	<h:outputText value="Ürün No" id="state_name"/>
		                   	</f:facet>
		                   	<h:outputText value="#{urun.urunno}" id="cap_state"/>
		               	</rich:column>
		               	<rich:column sortable="true" sortBy="#{urun.adi}" id="col_3" 
		               		filterBy="#{urun.adi}" filterEvent="onkeyup" width="330px" label="Ürün Adı">
		                   	<f:facet name="header">
		                    	<h:outputText value="Ürün Adı" id="state_capital"/>
		                   	</f:facet>
		                   	<h:outputText value="#{urun.adi} - #{urun.ambalaj}" id="cap_name"/>
		               	</rich:column>		               	
		           	</rich:extendedDataTable>
	           <rich:datascroller for="table" maxPages="5"/>
	        </h:panelGrid>
	        
	        <h:panelGrid columns="2" style="margin-left: 37%;" >
	        	<a:commandButton value="Tamam" style=" width : 60px;" action="#{isemiretutHome.takeSelection()}" reRender="seciliUrunBilgisi,extendedDataTableField,save,update" onclick="#{rich:component('popup')}.hide()"/>
	        	<a:commandButton value="İptal" style=" width : 60px;" action="#{isemiretutHome.clearSelectedUrun()}" reRender="seciliUrunBilgisi,extendedDataTableField,save,update" onclick="#{rich:component('popup')}.hide()" />
	        </h:panelGrid>
		</a:form>
    </rich:modalPanel>


</ui:define>

</ui:composition>
